home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 104 / MacAddict_104_2005-04.iso / Software / Internet & Communication / WordPress 1.2.2 freeware.dmg / wordpress / wp-trackback.php < prev    next >
Encoding:
PHP Script  |  2004-04-25  |  2.9 KB  |  91 lines

  1. <?php
  2. require(dirname(__FILE__) . '/wp-config.php');
  3.  
  4. // trackback is done by a POST
  5. $request_array = 'HTTP_POST_VARS';
  6. $tb_id = explode('/', $_SERVER['REQUEST_URI']);
  7. $tb_id = intval($tb_id[count($tb_id)-1]);
  8. $tb_url = $_POST['url'];
  9. $title = $_POST['title'];
  10. $excerpt = $_POST['excerpt'];
  11. $blog_name = $_POST['blog_name'];
  12.  
  13. require('wp-blog-header.php');
  14.  
  15. if ( (($p != '') && ($p != 'all')) || ($name != '') ) {
  16.     $tb_id = $posts[0]->ID;
  17. }
  18.  
  19. if (empty($title) && empty($tb_url) && empty($blog_name)) {
  20.     // If it doesn't look like a trackback at all...
  21.     header('Location: ' . get_permalink($tb_id));
  22. }
  23.  
  24. if ((strlen(''.$tb_id)) && (empty($_GET['__mode'])) && (strlen(''.$tb_url))) {
  25.  
  26.     @header('Content-Type: text/xml');
  27.  
  28.     if (!get_settings('use_trackback'))
  29.         trackback_response(1, 'Sorry, this weblog does not allow you to trackback its posts.');
  30.  
  31.     $pingstatus = $wpdb->get_var("SELECT ping_status FROM $tableposts WHERE ID = $tb_id");
  32.  
  33.     if ('closed' == $pingstatus)
  34.         trackback_response(1, 'Sorry, trackbacks are closed for this item.');
  35.  
  36.     $tb_url = addslashes($tb_url);
  37.     $title = strip_tags($title);
  38.     $title = (strlen($title) > 255) ? substr($title, 0, 252).'...' : $title;
  39.     $excerpt = strip_tags($excerpt);
  40.     $excerpt = (strlen($excerpt) > 255) ? substr($excerpt, 0, 252).'...' : $excerpt;
  41.     $blog_name = htmlspecialchars($blog_name);
  42.     $blog_name = (strlen($blog_name) > 255) ? substr($blog_name, 0, 252).'...' : $blog_name;
  43.  
  44.     $comment = '<trackback />';
  45.     $comment .= "<strong>$title</strong>\n$excerpt";
  46.  
  47.     $author = addslashes(stripslashes(stripslashes($blog_name)));
  48.     $email = '';
  49.     $original_comment = $comment;
  50.     $comment_post_ID = $tb_id;
  51.  
  52.     $user_ip = $_SERVER['REMOTE_ADDR'];
  53.     $user_domain = gethostbyaddr($user_ip);
  54.     $now = current_time('mysql');
  55.     $now_gmt = current_time('mysql', 1);
  56.  
  57.     $comment = convert_chars($comment);
  58.     $comment = format_to_post($comment);
  59.  
  60.     $comment_author = $author;
  61.     $comment_author_email = $email;
  62.     $comment_author_url = $tb_url;
  63.  
  64.     $author = addslashes($author);
  65.  
  66.     $comment_moderation = get_settings('comment_moderation');
  67.     $moderation_notify = get_settings('moderation_notify');
  68.  
  69.     if(check_comment($author, $email, $url, $comment, $user_ip)) {
  70.         $approved = 1;
  71.     } else {
  72.         $approved = 0;
  73.     }
  74.  
  75.     $result = $wpdb->query("INSERT INTO $tablecomments 
  76.     (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved)
  77.     VALUES 
  78.     ('$comment_post_ID', '$author', '$email', '$tb_url', '$user_ip', '$now', '$now_gmt', '$comment', '$approved')
  79.     ");
  80.  
  81.     if (!$result) {
  82.         die ("There is an error with the database, it can't store your comment...<br />Please contact the webmaster.");
  83.     } else {
  84.         $comment_ID = $wpdb->get_var('SELECT last_insert_id()');
  85.         if (get_settings('comments_notify'))
  86.             wp_notify_postauthor($comment_ID, 'trackback');
  87.         trackback_response(0);
  88.         do_action('trackback_post', $comment_ID);
  89.     }
  90. }
  91. ?>